/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmVentanaMantenerPerfil.java
 *
 * Created 
 */

package GUI.Seguridad;


import BusinessEntity.*;
import BusinessLogic.*;
import com.toedter.calendar.JDateChooser;
import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;
import GUI.Mensajes.*;
import GUI.Principal.frmVentanaPrincipal;
import java.util.Date;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Bernabe Yanac
 */
public class frmVentanaMantenerPerfil extends javax.swing.JFrame {
    private UsuarioBE objUsuarioBE;

    List<PerfilBE> arrePerfilesBE ;
    private PerfilBE objPerfilBE = new PerfilBE();
    private PerfilBL objPerfilBL = new PerfilBL();
    private ArrayList<PerfilBE> arrPerfiles = new ArrayList<PerfilBE>();
    int intTamañoNombre=1;
     // esto es para auditoria, valido para todos los modulos
        private LogUsuarioBE objLogUsuarioBE;
        private LogUsuarioBL objLogUsuarioBL;
        private TransaccionBE objTransaccionBE;
        private TransaccionBL objTransaccionBL;
        private String ConsultaRealizada="Perfil";
        private String Accion=""; // si es registrar, modificar, eliminar
        private int codmodulo=3; // es 3 xq segun la tabla el codigo de modulo de usuario es 3
        private int codusuario=0; // el usuario que se logueo
        private int codlog=0;
        private boolean resp;
   //// fin de lo agregado para auditoria
    /** Creates new form frmVentanaMantenerPerfil */
    public frmVentanaMantenerPerfil() {
        initComponents();
        this.cmbModulo.addItem("SELECCIONE");
        this.cmbModulo.addItem("Documentos");
        this.cmbModulo.addItem("Evaluacion");
        this.cmbModulo.addItem("Seguridad");
        this.cmbModulo.addItem("Auditoría");
        validaciones();
         this.setTitle("Administrar Perfiles");
          cargarCombo();
//         this.txaBarraEstado.setFont(new Font("Dialog",Font.BOLD, 12));
         this.objUsuarioBE=objUsuarioBE;

    }

    public void validaciones(){
    }
public void cargarCombo(){


    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlBusquedaPerfil = new javax.swing.JPanel();
        pnlDatosPerfil = new javax.swing.JPanel();
        lblNombre = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        pnlFuncionalidad = new javax.swing.JPanel();
        lblModulo = new javax.swing.JLabel();
        cmbModulo = new javax.swing.JComboBox();
        pnlPerfiles = new javax.swing.JPanel();
        scpPerfil = new javax.swing.JScrollPane();
        tblPerfil = new javax.swing.JTable();
        btnNuevo = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        btnCerrar = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();
        btnBuscar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Mantener Perfil");

        pnlBusquedaPerfil.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Búsqueda de Perfil", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 12), java.awt.Color.blue)); // NOI18N

        pnlDatosPerfil.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Perfil", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 12), java.awt.Color.blue)); // NOI18N

        lblNombre.setFont(new java.awt.Font("Dialog", 0, 12));
        lblNombre.setText("Nombre :");

        txtNombre.setFont(new java.awt.Font("DejaVu Sans", 0, 12));
        txtNombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombreKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout pnlDatosPerfilLayout = new javax.swing.GroupLayout(pnlDatosPerfil);
        pnlDatosPerfil.setLayout(pnlDatosPerfilLayout);
        pnlDatosPerfilLayout.setHorizontalGroup(
            pnlDatosPerfilLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPerfilLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(lblNombre)
                .addGap(18, 18, 18)
                .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlDatosPerfilLayout.setVerticalGroup(
            pnlDatosPerfilLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPerfilLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosPerfilLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNombre)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlFuncionalidad.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Funcionalidad", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 12), java.awt.Color.blue)); // NOI18N

        lblModulo.setFont(new java.awt.Font("Dialog", 0, 12));
        lblModulo.setText("Modulo :");

        cmbModulo.setFont(new java.awt.Font("DejaVu Sans", 0, 12));

        javax.swing.GroupLayout pnlFuncionalidadLayout = new javax.swing.GroupLayout(pnlFuncionalidad);
        pnlFuncionalidad.setLayout(pnlFuncionalidadLayout);
        pnlFuncionalidadLayout.setHorizontalGroup(
            pnlFuncionalidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFuncionalidadLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(lblModulo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addComponent(cmbModulo, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31))
        );
        pnlFuncionalidadLayout.setVerticalGroup(
            pnlFuncionalidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFuncionalidadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlFuncionalidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblModulo)
                    .addComponent(cmbModulo, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlBusquedaPerfilLayout = new javax.swing.GroupLayout(pnlBusquedaPerfil);
        pnlBusquedaPerfil.setLayout(pnlBusquedaPerfilLayout);
        pnlBusquedaPerfilLayout.setHorizontalGroup(
            pnlBusquedaPerfilLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBusquedaPerfilLayout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(pnlDatosPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                .addComponent(pnlFuncionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22))
        );
        pnlBusquedaPerfilLayout.setVerticalGroup(
            pnlBusquedaPerfilLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBusquedaPerfilLayout.createSequentialGroup()
                .addGroup(pnlBusquedaPerfilLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlDatosPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlFuncionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pnlPerfiles.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Perfiles", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 12), java.awt.Color.blue)); // NOI18N

        tblPerfil.setFont(new java.awt.Font("DejaVu Sans", 0, 12)); // NOI18N
        tblPerfil.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Perfil", "Estado"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblPerfil.setColumnSelectionAllowed(true);
        tblPerfil.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        scpPerfil.setViewportView(tblPerfil);
        tblPerfil.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tblPerfil.getAccessibleContext().setAccessibleParent(pnlPerfiles);

        javax.swing.GroupLayout pnlPerfilesLayout = new javax.swing.GroupLayout(pnlPerfiles);
        pnlPerfiles.setLayout(pnlPerfilesLayout);
        pnlPerfilesLayout.setHorizontalGroup(
            pnlPerfilesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPerfilesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scpPerfil, javax.swing.GroupLayout.DEFAULT_SIZE, 669, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlPerfilesLayout.setVerticalGroup(
            pnlPerfilesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPerfilesLayout.createSequentialGroup()
                .addComponent(scpPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnNuevo.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Add.png"))); // NOI18N
        btnNuevo.setText("Nuevo");
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        btnModificar.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        btnModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Editar.png"))); // NOI18N
        btnModificar.setText("Modificar");
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });

        btnEliminar.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        btnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Eliminar.png"))); // NOI18N
        btnEliminar.setText("Eliminar");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });

        btnCerrar.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        btnCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Cancelar.png"))); // NOI18N
        btnCerrar.setText("Cancelar");
        btnCerrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCerrarMouseClicked(evt);
            }
        });
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });

        btnLimpiar.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        btnLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Limpiar.png"))); // NOI18N
        btnLimpiar.setText("Limpiar");
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });

        btnBuscar.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        btnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/BuscarComputadora.png"))); // NOI18N
        btnBuscar.setText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlBusquedaPerfil, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnNuevo)
                        .addGap(18, 18, 18)
                        .addComponent(btnModificar)
                        .addGap(18, 18, 18)
                        .addComponent(btnEliminar)
                        .addGap(18, 18, 18)
                        .addComponent(btnLimpiar)
                        .addGap(18, 18, 18)
                        .addComponent(btnBuscar)
                        .addGap(18, 18, 18)
                        .addComponent(btnCerrar))
                    .addComponent(pnlPerfiles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnNuevo)
                    .addComponent(btnModificar)
                    .addComponent(btnEliminar)
                    .addComponent(btnLimpiar)
                    .addComponent(btnBuscar)
                    .addComponent(btnCerrar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlBusquedaPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlPerfiles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

     private void buscarPerfil(){
        PerfilBE objPerfil=new PerfilBE();
        String Modulo;
        Modulo=(String)this.cmbModulo.getSelectedItem();
        String nombrePerfil = "";
        nombrePerfil = this.txtNombre.getText();
        this.objPerfilBE.setPerfil(nombrePerfil);
        try {
            arrPerfiles = this.objPerfilBL.listarPerfilModulo(objPerfilBE,Modulo);
        } catch (Exception e) {
           JOptionPane.showMessageDialog(null,e.getMessage(),"Excepcion ",JOptionPane.ERROR_MESSAGE);
        }
        if(arrPerfiles!=null){
            if (!arrPerfiles.isEmpty()){
                        cargarTabla(null,null,arrPerfiles);
            }else{
                JOptionPane.showMessageDialog(null,"Error en llenar la Tabla","Mensaje",JOptionPane.ERROR_MESSAGE);
            }
        }else{
            JOptionPane.showMessageDialog(null,"No se encontro ningun Pefil","Mensaje",JOptionPane.ERROR_MESSAGE);
        }
    }
    private void cargarTabla(String fechaInicial,String fechaFinal, List<PerfilBE> arrePerfilesBE ){
        DefaultTableModel model = (DefaultTableModel) this.tblPerfil.getModel();
        model.setNumRows(0);
       for (int i=0 ;i< arrePerfilesBE.size();i++){
            if (arrePerfilesBE.get(i).getEstado().equals("Activo") || arrePerfilesBE.get(i).getEstado().equals("ACTIVO") || 1==1) {
//               Object[]  newRow = {arrePerfilesBE.get(i).getPerfil(),arrePerfilesBE.get(i).getEstado(),arrePerfilesBE.get(i).getDteFechaCreacion()};
               Object[]  newRow = {arrePerfilesBE.get(i).getPerfil(),arrePerfilesBE.get(i).getEstado()};
               model.addRow(newRow);
            }
        }
        this.tblPerfil.setModel(model);
    }

    private void btnCerrarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCerrarMouseClicked
        // TODO add your handling code here:
        this.setVisible(false);
}//GEN-LAST:event_btnCerrarMouseClicked

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
}//GEN-LAST:event_btnCerrarActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        // TODO add your handling code here:
        buscarPerfil();
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
        // TODO add your handling code here:
        PerfilBE objPerfil2 = new PerfilBE();
        String Modulo;
        Modulo=(String)this.cmbModulo.getSelectedItem();
        String nombrePerfil = "";
        nombrePerfil = this.txtNombre.getText();
        objPerfil2.setPerfil(nombrePerfil);

         if(this.tblPerfil.getSelectedRow()==-1){
             String texto="Error - por favor seleccionar un usuario";
            new dlgAvisoError(javax.swing.JOptionPane.getFrameForComponent(this),true, texto).setVisible(true);
        }else{
            PerfilBE objPerfil= this.arrPerfiles.get(this.tblPerfil.getSelectedRow());
            if ((objPerfil.getEstado().equals("Activo")) || (objPerfil.getEstado().equals("ACTIVO"))){
                frmVentanaPerfil ventanaPerfil = new frmVentanaPerfil(objPerfil,2);
                ventanaPerfil.setVisible(true);
                limpiar();
                
                    arrPerfiles = null;
                    arrPerfiles = this.objPerfilBL.listarPerfilModulo(objPerfil2,Modulo);
                    cargarTabla(null,null,arrPerfiles);
            }
        }
    }//GEN-LAST:event_btnModificarActionPerformed
public TransaccionBE cargarTransaccion(UsuarioBE objUsuarioBE,String Accion,int codmodulo,int codusuario,int codlog){

        Date fecha = new Date();

        objTransaccionBE = new TransaccionBE();
        objTransaccionBE.setFecha(fecha);
//        objTransaccionBE.setObjUsuarioBE(objUsuarioBE);
//        objTransaccionBE.setCodModulo(codmodulo);
//        objTransaccionBE.setConsultaRealizada(ConsultaRealizada);
//        objTransaccionBE.setAccion(Accion);
//        objTransaccionBE.setCodlog(codlog);


         return   objTransaccionBE;

    }
    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
    // TODO add your handling code here:
        UsuarioBE objUsuario =new UsuarioBE();
         if(this.tblPerfil.getSelectedRow()==-1){
             String texto="Error, por favor seleccionar un usuario";
        }else{
            PerfilBE objPerfil= this.arrPerfiles.get(this.tblPerfil.getSelectedRow());
            if ((objPerfil.getEstado().equals("Activo")) || (objPerfil.getEstado().equals("ACTIVO")))  {
                 dlgAvisoConfirmacion aviso=new dlgAvisoConfirmacion(javax.swing.JOptionPane.getFrameForComponent(this),true,"Desea continuar con la operacion?");
                aviso.setVisible(true);
                 if(aviso.getReturnStatus()==1) {
                    if (objPerfilBL.eliminarperfil(objPerfil, 2)){
//                         se agrega para auditoria
//                          objTransaccionBE = new TransaccionBE();
//                          objTransaccionBL = new TransaccionBL();
//                          Accion="Eliminar";
//
//                          objUsuario=frmVentanaPrincipal.usuarioActual;
//                           codlog=frmVentanaPrincipal.logActual;
//                          codusuario = objUsuario.getCodUsuario();
//                          objTransaccionBE = cargarTransaccion(objUsuario,Accion,codmodulo,codusuario,codlog);
//                          resp=objTransaccionBL.registrarTransaccion(objTransaccionBE);
//                       fin de lo agregado para auditoria
                        String texto = "Perfil Eliminado correctamente";
                    }
                    String Modulo;
                    Modulo=(String)this.cmbModulo.getSelectedItem();
                    arrPerfiles = this.objPerfilBL.listarPerfilModulo(objPerfilBE,Modulo);
                    cargarTabla(null,null,arrPerfiles);
                 }
            }else{
            }
        }
    }//GEN-LAST:event_btnEliminarActionPerformed

    private void txtNombreKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyTyped
        // TODO add your handling code here:
            char caracter = evt.getKeyChar();
        this.intTamañoNombre=this.txtNombre.getText().length()+1;
        if( (caracter >= '0') && (caracter <= '9') ){
            evt.consume(); // ignorar el evento de teclado
        }

        if (this.intTamañoNombre > 50){
            evt.consume();
        }
        if ((caracter == '\b') && (this.intTamañoNombre > 1)){
            this.intTamañoNombre -= 1;
        } else
            if ( (this.intTamañoNombre <=50) && (caracter != '\b')
                 && ( (caracter < '0') || (caracter > '9')) ){
            this.intTamañoNombre += 1;
        }
    }//GEN-LAST:event_txtNombreKeyTyped

    private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed
        // TODO add your handling code here:
        limpiar();
    }//GEN-LAST:event_btnLimpiarActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
            // TODO add your handling code here:
        new frmVentanaPerfil(null,1).setVisible(true);
        this.dispose();
    }//GEN-LAST:event_btnNuevoActionPerformed

    private void limpiar(){
        this.txtNombre.setText("");
        this.cmbModulo.setSelectedIndex(0);
        DefaultTableModel modelo= new DefaultTableModel();
        modelo =(DefaultTableModel)tblPerfil.getModel();
        while(modelo.getRowCount()>0)
            modelo.removeRow(0);
    }

//    /**
//    * @param args the command line arguments
//    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new frmVentanaMantenerPerfil().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnCerrar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JComboBox cmbModulo;
    private javax.swing.JLabel lblModulo;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JPanel pnlBusquedaPerfil;
    private javax.swing.JPanel pnlDatosPerfil;
    private javax.swing.JPanel pnlFuncionalidad;
    private javax.swing.JPanel pnlPerfiles;
    private javax.swing.JScrollPane scpPerfil;
    private javax.swing.JTable tblPerfil;
    private javax.swing.JTextField txtNombre;
    // End of variables declaration//GEN-END:variables

}
